<?php

App::uses('Debugger', 'Utility');
App::uses('CakeLog', 'Log');
App::uses('ExceptionRenderer', 'Error');
App::uses('AppExceptionRenderer', 'Error');
App::uses('AppController', 'Controller');

class AppException {

  public static function handleException($exception) {
    $message = sprintf("[%s] %s\n%s",
                    get_class($exception),
                    $exception->getMessage(),
                    $exception->getTraceAsString()
    );
    CakeLog::write(LOG_ERR, $message);
    $error = new AppExceptionRenderer($exception);
    $error->render();
    // ...
  }

}

/*
  CakePHP Error and Exception Handling

  Errors
  http://book.cakephp.org/2.0/en/development/errors.html


  Exceptions
  http://book.cakephp.org/2.0/en/development/exceptions.html

  Logging
  book.cakephp.org/2.0/en/core-libraries/logging.html

 * *Random article about dealing with exceptions
  http://nuts-and-bolts-of-cakephp.com/2008/08/29/dealing-with-errors-in-cakephp/
 */
?>
